package com.flex.showdoc4j.generator;

import com.flex.core.enums.SdkCommitType;
import com.flex.core.enums.SdkType;
import lombok.Data;

import java.io.*;

/**
 * 生成后的文件
 * @author ganlt
 * @since 2019/10/25 10:14
 */
@Data
public class SdkFile {
    /**
     * 文件名
     */
    private String fileName;
    /**
     * 文件内容
     */
    private String body;
    /**
     * 文件格式 .js .java
     */
    private String format;

    private SdkFile() {}

    /**
     * 实现文件
     * @author ganlt
     * @date 2019/10/25
     * @param
     * @return java.io.File
     */
    public File toFile(String dir) {
        return new File(dir + File.separator + this.getFileName() + "." + this.getFormat());
    }

    public FileInputStream toFileStream() {
        return null;
    }

    public static SdkFile createSdkFile(String name, SdkType sdkCommitType, String body) {
        SdkFile sdkFile = new SdkFile();
        sdkFile.fileName = name;
        sdkFile.format = sdkCommitType.getPrefix();
        sdkFile.body = body;
        return sdkFile;
    }
}
